/*----------------------+
|	Dungeon Generator	|
|	-----------------	|
|	Class that is used	|
|	to design random	|
|	dungeon levels		|
+----------------------*/

#pragma once

#include <Windows.h>

// Forward Declarations
class Tile;
class Level;
class Enemy;
class Room;
class Chest;
class Hazard;

class Dungeon
{
	friend class GamePlayState;
	friend class TutorialState;

public:

	// Enumeration for which level is being generated
	enum DUNGEON {DUNGEON_RESEARCHLAB, DUNGEON_POWERPLANT, DUNGEON_MILITARYBASE, DUNGEON_RECYCLINGCENTER};

	// Types of rooms that can be generated
	enum ROOMTYPES {NORMAL, SPAWN, BOSS};

	// Get access to the singleton
	static Dungeon* GetInstance();

	// Generate a level
	Level* GenerateLevel(DUNGEON levelToGenerate);

	// Build the tutorial level
	Level* GenerateTutorial(void);

private:

	// Trilogy
	Dungeon(void);
	Dungeon(const Dungeon& other);
	Dungeon& operator=(const Dungeon& other);
	~Dungeon(void);

	// Data to be held for room and tile creation
	DUNGEON currentDungeon;
	int roomCount;

	// Create rooms
	Room* CreateRoom(int x, int y, ROOMTYPES type = NORMAL, Level* l = NULL);

	// Types of tiles 
	enum TileTypes {TILE_IMAGE = 1, TILE_COLLISION, TILE_TRIGGER, TILE_SPAWN};

	// Create individual tiles
	Tile* CreateTile(TileTypes tiletype, int x, int y, RECT* imageRect, char* trigger = "");

	// Build a hall to connect rooms or build doors
	enum Side { UP, DOWN, LEFT, RIGHT };
	void CreateHall(Side wall, Room* room, int roomx, int roomy);

	// Fill in the walls where there are no doors
	void CreateWall(Side wall, Room* room, int roomx, int roomy);
	void FillRoomWalls(Room* room, int roomx, int roomy);

	// Point structure to store locations more easily
	struct Point
	{
		int x;
		int y;

		inline Point(int i = 0,int j = 0) { x = i; y = j; }
	};

	// Spawn a chest
	Chest* SpawnChest(int roomx,int roomy);

	// Spawn a hazard
	Hazard* CreateHazard(int roomx, int roomy);

	// Spawn the level's boss
	Enemy* SpawnBoss(int roomx, int roomy, Level* l);

	// Create a lock for the room
	void LockRoom(int roomx, int roomy, Room* roomToLock, int side);

	// Map of the rooms
	Room* rooms[5][5];

	// Is it making the tut?
	bool Tutorial;
};